package com.haozhen.streamtransformation;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author haozhen
 * @email haozh@ync1.com
 * @date 2021/2/25  23:29
 */
public class MapDemo {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<String> stringDataStreamSource = env.fromElements("haozhen", "licao", "zhangxu");

        SingleOutputStreamOperator<String> map = stringDataStreamSource.map(value -> {
            return value + " Student";
        });

        map.print();

        SingleOutputStreamOperator<String> haozhen = map.filter(value -> {
            return !value.startsWith("haozhen");
        });

        haozhen.print();
        env.execute();
    }
}
